import { PolygonGeometry, PolygonHierarchy, Cartesian3,EllipsoidSurfaceAppearance, GroundPrimitive, GeometryInstance,Material} from 'cesium';
import waterimg from './baseimg'
const waterLayer = function(arrayPoints) {
    var polygon = new PolygonGeometry({
        polygonHierarchy : new PolygonHierarchy(Cartesian3.fromDegreesArray(arrayPoints)),
        extrudedHeight:120,
        // perPositionHeight:true,
        height:0,
        vertexFormat : EllipsoidSurfaceAppearance.VERTEX_FORMAT
    });
    this.River = new GroundPrimitive({
        geometryInstances : new GeometryInstance({
            geometry :polygon
        }),
        appearance : new EllipsoidSurfaceAppearance({
            aboveGround : true,
            flat  : true
        }),
        show : true
    });
    var River1_Material = new Material({
        fabric : {
            type : 'Water',
            uniforms : {
                baseWaterColor:{
                    alpha: 1,
                    blue: 0.1,
                    green: 0.3,
                    red: 0.3,
                },
                normalMap:waterimg,
                frequency: 800.0,
                animationSpeed: 0.01,
                amplitude: 8
            }
        }
    });
    this.River.appearance.material = River1_Material;
}
waterLayer.prototype={
    addTo:function(scene){
        scene.primitives.add(this.River); //添加到场景
    },
    goto:function(){

    }
}
export default waterLayer